package com.java90.homework.result;

import lombok.Data;

/**
 *  返回结果封装
 * */
@Data
public class R {
    private String code;
    private String msg;
    private Object data;

    public static R success(String message){
        R m = new R();
        m.setCode("200");
        m.setData(null);
        m.setMsg(message);
        return m;
    }

    public static R success(String message, Object data){
        R m = new R();
        m.setCode("200");
        m.setData(data);
        m.setMsg(message);
        return m;
    }

    public static R fail(String message){
        R m = new R();
        m.setCode("400");
        m.setData(null);
        m.setMsg(message);

        return m;
    }

    public static R fail(String message, Object data){
        R m = new R();
        m.setCode("400");
        m.setData(data);
        m.setMsg(message);

        return m;
    }
}
